﻿<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <%@include file="../../common/include_list_head.jsp" %>
    <script type="text/javascript">
        function doRecharge() {
            var id = floatchickButton(1, "充值");
            if (id != false) {
                var url = "../business/rechargeByAdmin-input." + uri_suffix + "?wid=" + id;
                openWindow(url, 380, 260);
            }
        }
        /**********************抽取门户表t_user用户数据***************************/
        function extractUsers() {
            var url = "../id/idUser-extractUsers.action";
            showProgressBar();
            $.post(url, function (data) {
                window.setTimeout("AlertMsg('" + data + "')", 1000);
            });
        }
        function AlertMsg(data) {
            closeProgress();
            alert(data);
            location.replace(location.href);
        }

//        window.confirm = function(message) {
//            return top.Dialog.confirm(message,function(){doConfirm();});
//        };

        /**
         * 批量授权
         * @param type
         */
        function doEmpower(type) {
            if (type == 0) {
                var ids = floatchickButton(0, "按勾选批量授权");
                if (ids != false) {
                    var url = "${basePath}/jsonVisitor/ajaxBiz-empower.action?" + (new Date()).getTime();
                    $.post(url, {ids: ids, roleid: $("#roleid", parent.document).val()}, function () {
                        alert("按勾选批量授权成功！");
                        window.location.reload();
                    });
                }
            } else {
                $("#msg").val("empower");
                if(window.confirm("是否按查询结果批量授权")){
                    var url = "${basePath}/jsonVisitor/ajaxBiz-empower.action?" + (new Date()).getTime();
                    $.post(url, {ids: ids, roleid: $("#roleid", parent.document).val()}, function () {
                        alert("按查询结果批量授权成功！");
                        window.location.reload();
                    });
                }
            }
        }
        /**
         * 批量取消授权
         * @param type
         */
        function doDelete(type) {
            if (type == 0) {
                var ids = floatchickButton(0, "按勾选批量取消授权");
                if (ids != false) {
                    var url = "${basePath}/jsonVisitor/ajaxBiz-dodelete.action?" + (new Date()).getTime();
                    $.post(url, {ids: ids, roleid: $("#roleid", parent.document).val()}, function () {
                        alert("按勾选批量取消授权成功！");
                        window.location.reload();
                    });
                }
            } else {
                $("#msg").val("delete");
                if(window.confirm("按查询结果批量取消授权")){
                    var url = "${basePath}/jsonVisitor/ajaxBiz-dodelete.action?" + (new Date()).getTime();
                    $.post(url, {ids: ids, roleid: $("#roleid", parent.document).val()}, function () {
                        alert("按查询结果批量取消授权成功！");
                        window.location.reload();
                    });
                }
            }
        }
        /**
         * 全部授权
         */
        function doConfirm() {
            var msg = $("#msg").val();
            if(msg=="empower"){//全部授权
                var url = "${basePath}/jsonVisitor/ajaxBiz-empower.action?" + (new Date()).getTime();
                $.post(url, {roleid: $("#roleid", parent.document).val()}, function () {
                    alert("全部授权成功！");
                    window.location.reload();
                });
            }else if(msg == "delete"){//全部删除授权
                var url = "${basePath}/jsonVisitor/ajaxBiz-dodelete.action?" + (new Date()).getTime();
                $.post(url, {roleid: $("#roleid", parent.document).val()}, function () {
                    alert("全部删除成功！");
                    window.location.reload();
                });
            }else if(msg =="chanage"){//是否启用

                var state =$("#state").val();
                var ids = $("#ids").val();
                var url_bak = window.location.href;
                var parms = null;
                if (document.getElementById("changestate_parms")) {
                    parms = document.getElementById("changestate_parms").value;
                } else {
                    alert("页面缺少必要信息(操作对象或主键名或菜单编号)!");
                    return false;
                }
                var url = "../jsonVisitor/ajaxSys-doUniChangeState.action?"
                        + (new Date()).getTime();

                $.getJSON(url, {
                    wid : ids,
                    state : state,
                    parms : parms
                }, function(data) {
                    document.forms[0].action = url_bak;//还原URL，防止点查询按钮却执行删除！
                    if(turnPageTickOff){
                        document.cookie = menuid + "=;";
                        floatShowFloat();
                    }
                    document.forms[0].submit();
                });
            }

        }

        function doAuthoriza(obj){
            if(obj==1){
                window.location.href="${basePath}/id/idUser-list.action?type=role";
            }else{
                var roleid = $("#roleid", parent.document).val();
                window.location.href="${basePath}/id/idUser-list.action?type=role&flag=authoriza&roleid="+roleid;
            }

        }

        function doUniChangeState(state, obj) {
            super_doUniChangeState(state, obj);
        }
        /**
         * 审核通过选中的记录
         */
        function super_doUniChangeState(state, obj) {
            var shzt = $(obj).find("span").html();
            var ids = floatchickButton(0,shzt);
            if(ids != false){
                $("#msg").val("chanage");
                $("#state").val(state);
                $("#ids").val(ids);
                window.confirm("您确定要改变已选中的这些数据的状态吗？")
            }
        }
        /**
        * 重置密码
         */
        function resetUserPwd(){
            var ids = floatchickButton(1, "重置密码的用户");
            var pwd =  "000000";
            if (ids != false) {
                var url = "${basePath}/s/uc/pwd/admin/"+ids+"/"+pwd+"?" + (new Date()).getTime();
                $.post(url, {}, function (res) {
                    if(res.indexOf("成功")!=-1){
                        alert("成功重置用户的密码为六个零！");
                    }else{
                        alert(res);
                    }
                });
            }
        }
    </script>
</head>

<body>
<div id="scrollContent">
    <s:hidden id="msg"/>
    <s:hidden id="ids"/>
    <s:hidden id="state"/>
    <s:if test="actionErrors.size()>0 || actionMessages.size()>0 || fieldErrors.size()>0">
        <div id="SystemErrorMessage">
            <s:actionerror/>
            <s:actionmessage/>
            <s:fielderror/>
        </div>
    </s:if>

    <div class="box_tool_mid padding_right5">
        <div class="center">
            <div class="left">
                <div class="right">
                    <div class="padding_top8 padding_left10">
                        <table>
                            <s:form theme="simple" name="ysform">
                                <s:hidden name="pager.formname" value="ysform"/>
                                <s:hidden name="pager.currentPageno" id="yspager_currentPageno"/>
                                <tr>
                                    <td>&nbsp;</td>
                                    <td align="center" nowrap="nowrap" class="">&nbsp;状态：
                                        <s:select id="state" name="tsysUser.state" list="#{'-1':'全部','1':'可用','0':'禁用'}"
                                                  listKey="key" listValue="value" onchange="super_doSearch()"/>
                                    </td>
                                    <td align="center" nowrap="nowrap" class="">&nbsp;登录标识：
                                        <s:textfield name="tsysUser.userloginid" id="userLoginId" maxlength="50"
                                                     size="10"/>
                                    </td>
                                    <td align="center" nowrap="nowrap" class="">&nbsp;用户名称：
                                        <s:textfield name="tsysUser.username" id="userName" maxlength="30" size="15"/>
                                    </td>
                                    <td align="center" nowrap="nowrap" class="">&nbsp;所属部门：
                                        <s:textfield name="tsysUser.depart.departname" id="departname" maxlength="30"
                                                     size="20"/>
                                    </td>
                                    <s:if test="#type!='role'.toString()">
                                        <td align="center" nowrap="nowrap" class="">&nbsp;角色：
                                            <s:select id="qrole" name="qrole" value="#parameters.qrole[0]"
                                                      list="allRoles"
                                                      headerKey="" headerValue="----全部角色----" listKey="roleid"
                                                      listValue="rolename" onchange="super_doSearch()"/>
                                        </td>
                                    </s:if>
                                    <s:else>
                                        <td align="center" nowrap="nowrap" class="">&nbsp;用户类型：
                                            <s:select id="yhlx" name="yhlx"
                                                      list="getYhlxList()"
                                                      headerKey="" headerValue="----请选择----" listKey="id"
                                                      listValue="caption"/>
                                        </td>
                                    </s:else>
                                    <td>
                                        <button onclick="super_doSearch()" type="button"><span
                                                class="icon_find">查询</span></button>
                                        <button onclick="doreset();" type="button"><span class="icon_recycle">重置</span>
                                        </button>
                                    </td>
                                </tr>
                            </s:form>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div id="userRoleMenuButton">
        <s:if test="#type!='role'.toString()">
            <button onclick="openEntity()" type="button"><span class="icon_add" title="">新增</span></button>
            <button onclick="doModify()" type="button"><span class="icon_edit" title="">修改</span></button>
            <button onclick="doRemove()" type="button"><span class="icon_delete" title="">删除</span></button>
            <button onclick="doUniChangeState(1,this)" type="button"><span class="icon_ok" title="">启用</span></button>
            <button onclick="doUniChangeState(0,this)" type="button"><span class="icon_no" title="">禁用</span></button>
            <button onclick="resetUserPwd();" type="button" title="重置密码"><span class="icon_reload" title="">重置密码</span></button>
            <s:property value="userRoleMenuButton" escape="false"/>
            <s:hidden name="changestate_parms" id="changestate_parms"
                      value="%{@com.apexedu.util.crypto.CipherUtil@encryptByAES('entityName:t_sys_user;idName:userid')}"/>
        </s:if>
        <s:else>
            <s:if test="#flagtype!='hide'.toString()">
            <button onclick="doAuthoriza('0')" type="button"><span class="icon_find" title="">显示已授权</span></button>
            </s:if>
            <s:else>
                <button onclick="doAuthoriza('1')" type="button"><span class="icon_find" title="">显示全部</span></button>
            </s:else>
            <button onclick="doEmpower()" type="button"><span class="icon_add" title="">全部授权</span></button>
            <button onclick="doEmpower('0')" type="button"><span class="icon_edit" title="">勾选授权</span></button>
            <button onclick="doDelete()" type="button"><span class="icon_delete" title="">全部取消</span></button>
            <button onclick="doDelete('0')" type="button"><span class="icon_no" title="">勾选取消</span></button>
        </s:else>
    </div>
    <div>
        <table class="tableStyle" headFixMode="true"
               useMultColor="false" useCheckBox="false">
            <tr>
                <th width="25"></th>
                <th width="100">登录标识</th>
                <th width="120">用户名称</th>
                <th width="150">所属部门</th>
                <th width="80">累计登录次数</th>
                <th width="100">上次登录时间</th>
                <th width="100">上次登录IP</th>
                <th width="80">状态</th>
            </tr>
            <s:iterator value="resultData">
                <tr>
                    <td><s:checkbox id="%{userid}" name="selectNode" fieldValue="%{userid}"/></td>
                    <td>
                        <a href="javascript:openEntity('<s:property value="userid"/>')"><font color="blue"><s:property
                                value="userloginid"/></font></a>
                    </td>
                    <td>
                        <s:property value="username"/>
                    </td>
                    <td>
                        <s:property value="depart.departname"/>
                    </td>
                    <td>
                        <s:property value="logintimes"/>
                    </td>
                    <td>
                        <s:date name="lastlogintime" format="yyyy-MM-dd HH:mm:ss"/>
                    </td>
                    <td>
                        <s:property value="lastloginip"/>
                    </td>
                    <td>
                        <s:if test="state==0">禁用</s:if>
                        <s:else>可用</s:else>
                    </td>
                </tr>
            </s:iterator>
        </table>
    </div>

    <div style="height: 45px;">
        <div id="pagelist" style="display: none">
            <s:property value="pager.postToolBar" escape="false"/>
        </div>

        <div class="clear"></div>
    </div>

</div>
</body>
</html>
